from cnpy import *
from 图片资源 import *

# 第一个技能在软件中的位置
skill_first_position = (300, 900)
# 技能优先级分为6级：
# 0：学习/大招，1：范围/连击/持续/双倍/加速等，2：特殊增伤，3：控制/低伤，4：其他（伤害等），5：特殊效果（最低优先级，可以不写）
skill_level = 5
log_ = {
    "冰爆": [
        # { "name": 学习冰爆, "level": 0, "log": "冰爆术" },
        {"name": 冰爆精通, "level": 0, "log": "冰系法术精通"},
        # {"name": 冰爆扩张, "level": 1, "log": "冰爆扩张"},
        # {"name": 冰爆连击, "level": 1, "log": "冰爆连击"},
        # {"name": 冰爆核心, "level": 1, "log": "冰爆核心"},
        # {"name": 冰爆绝对冰封, "level": 2, "log": "冰爆绝对冰封"},
        # {"name": 冰爆增幅, "level": 2, "log": "冰爆增幅"},
        # {"name": 冰爆急冻, "level": 3, "log": "冰爆急冻"},
        # { "name": 冰爆寒冰刺骨, "level": 3, "log": "冰爆寒冰刺骨" },
        # { "name": 冰爆碎冰, "level": 5, "log": None },
        # { "name": 冰爆碎冰强化, "level": 5, "log": None },
        # {"name": 冰爆图标, "level": 4, "log": None},
    ],
    "莲舞": [
        # { "name": 学习莲舞, "level": 0, "log": "闪电莲舞" },
        {"name": 莲舞双生, "level": 0, "log": "莲舞双生"},
        # {"name": 莲舞双生1, "level": 0, "log": "莲舞双生"},
        # {"name": 莲舞增幅, "level": 2, "log": "莲舞增幅"},
        # {"name": 莲舞持续, "level": 3, "log": "莲舞持续"},
        # {"name": 莲舞加速, "level": 3, "log": "莲舞加速"},
        # {"name": 莲舞扩张, "level": 3, "log": "莲舞扩张"},
        # {"name": 莲舞奇点, "level": 3, "log": "莲舞奇点"},
        # {"name": 莲舞麻痹, "level": 4, "log": "莲舞麻痹"},
        # { "name": 莲舞牵引, "level": 5, "log": "莲舞牵引" },
        # {"name": 莲舞图标, "level": 4, "log": None},
    ],
    "冰锥": [
        # { "name": 学习冰锥, "level": 0, "log": "冰锥术" },
        # {"name": 冰锥寒冰神锥, "level": 0, "log": "冰锥寒冰神锥"},
        {"name": 冰锥连发, "level": 0, "log": "冰锥连发"},
        {"name": 冰锥齐射, "level": 0, "log": "冰锥齐射"},
        # {"name": 冰锥贯穿, "level": 2, "log": "冰锥贯穿"},
        # {"name": 冰锥增幅, "level": 2, "log": "冰锥增幅"},
        # {"name": 冰锥绝对零度, "level": 3, "log": "冰锥绝对零度"},
        # {"name": 冰锥重型, "level": 3, "log": "冰锥重型"},
        # { "name": 冰锥冻伤, "level": 3, "log": "冰锥冻伤" },
        # {"name": 冰锥分裂, "level": 4, "log": None},
        # {"name": 冰锥图标, "level": 4, "log": None},
    ],
    "豌豆": [
        {"name": 豌豆连发, "level": 3, "log": "豌豆连发"},
        # {"name": 豌豆爆炸, "level": 2, "log": "豌豆爆炸"},
        # {"name": 豌豆齐射, "level": 3, "log": "豌豆齐射"},
        # {"name": 豌豆分裂, "level": 3, "log": "豌豆分裂"},
        # {"name": 豌豆分裂爆炸, "level": 2, "log": "豌豆分裂爆炸"},
        # {"name": 豌豆增幅, "level": 2, "log": "豌豆增幅"},
        # { "name": 豌豆燃烧, "level": 3, "log": "豌豆燃烧" },
        {"name": 豌豆图标, "level": 4, "log": None},
    ],
    "火球": [
        {"name": 学习火球, "level": 0, "log": "火球术"},
        {"name": 火球三味真火, "level": 0, "log": "火球三味真火"},
        {"name": 火球连击2, "level": 0, "log": "火球连击2"},
        {"name": 火球连击, "level": 1, "log": "火球连击"},
        # {"name": 火球引燃, "level": 4, "log": "火球引燃"},
        {"name": 火球图标, "level": 4, "log": None},
    ],
    "闪电链": [
        {"name": 学习闪电链, "level": 0, "log": "闪电链"},
        {"name": 闪电传导, "level": 0, "log": "闪电传导"},
        # {"name": 闪电增幅, "level": 1, "log": "闪电增幅"},
        # {"name": 闪电高能, "level": 1, "log": "闪电高能"},
        # {"name": 闪电麻痹, "level": 2, "log": "闪电麻痹"},
        # {"name": 闪电感电, "level": 3, "log": "闪电感电"},
        # {"name": 闪电图标, "level": 4, "log": None},
    ],
    "城墙": [
        {"name": 城墙修复, "level": 2, "log": "城墙修复"},
    ]
}
skill_all = log_

# 技能排序 base_skill：传入的技能数组，例如： ["冰爆","豌豆"]
def skill_sort(base_skill):
    my_skill = []
    # 按技能等级循环
    for value in range(0, skill_level+1):
        for skill in base_skill:
            skills = skill_all[skill]
            for _skill in skills:
                if _skill["level"] == value:
                    my_skill.append(_skill)
    return my_skill

# 选择技能
def skill_select(截图, skills):
    find_skill = False

    for skill in skills:
        has_skill = 图像处理.找图(截图, skill["name"])
        if has_skill:
            find_skill = True
            键鼠.精准点击(has_skill["中心点"])
            # if skill["log"]:
            #     时间 = strftime("%Y-%m-%d %H:%M:%S")
            #     print(f'选择了技能：{skill["log"]} ')
            break
    if not find_skill:
            键鼠.精准点击(skill_first_position)
